import VuePlugin from '@vitejs/plugin-vue';
import styleImportPlugin from 'vite-plugin-style-import';
import path from 'path';
import { defineConfig } from 'vite';

function resolve(dir: string) {
    return path.join(__dirname, dir);
}

export default defineConfig({
    css: {
        preprocessorOptions: {
            less: {
                modifyVars: {
                    hack: `true; @import (reference) "${resolve('src/styles/variables.less')}";`
                },
                javascriptEnabled: true
            }
        }
    },
    plugins: [
        VuePlugin(),
        styleImportPlugin({
            libs: [
                {
                    libraryName: 'ant-design-vue',
                    esModule: true,
                    resolveStyle: (name) => {
                        return `ant-design-vue/es/${name}/style/index`;
                    }
                }
            ]
        })
    ],
    resolve: {
        alias: {
            '@': resolve('src'),
            '@assets': resolve('src/assets'),
            '@images': resolve('src/assets/images'),
            '@styles': resolve('src/styles'),
            '@components': resolve('src/components'),
            '@directives': resolve('src/directives'),
            '@filters': resolve('src/filters'),
            '@plugins': resolve('src/plugins'),
            '@mixins': resolve('src/mixins'),
            '@services': resolve('src/services'),
            '@constants': resolve('src/constants'),
            '@store': resolve('src/store'),
            '@views': resolve('src/views'),
            '@layouts': resolve('src/layouts'),
            '@helpers': resolve('src/helpers'),
            '@router': resolve('src/router')
        }
    }
});
